package com.lc1993929.actions;

/**
 * Created by LiuChang on 2017/5/8.
 */
public class ActionManager {
    public static Action createAction(String className) {
        //生产class对象
        Class clazz = null;
        //判断当前线程是否有该action线程运行
        try {
            clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        if (null == clazz) {
            try {
                clazz = Class.forName(className);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }

        //产生Action实例
        Action action = null;

        try {
            action = (Action) clazz.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }


        return action;
    }

}
